<?php
	class Template {
		var $phpself;
		var $navi_category;
		var $module_flag;
		public function __construct(){
			$this->phpself = &$GLOBALS['PHP_SELF'];
			$this->navi_category = &$GLOBALS['NAVI_CATEGORY'];
			//echo $this->phpself;
			$this->navi_category;
			//echo $this->navi_category;
		}

		########################################################################################################
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		# join agree                                                                                           #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		########################################################################################################





		########################################################################
		# 이용약관
		########################################################################
		public function terms_of_use() { ?>
			이용약관
		<?php }





		########################################################################
		# 개인정보보호정책
		########################################################################
		public function privacy_policy() { ?>
			개인정보보호정책
		<?php }





		########################################################################################################
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		# user                                                                                                 #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		########################################################################################################





		########################################################################
		# dev
		########################################################################
		public function dev($p_comment) { ?>
			<span style="border:1px solid red; line-height:30px;font-size:30px;height:443px;;background-color:red; color:yellow;font-weight:bold;width:100%;display:block;text-align:center;">
				<br /><br /><br /><br />개발중<br />
				/) /)<br />
				(='.'=);<br />
				o >{\\\> o<br />
				<span style="background-color:yellow;font-size:12px;color:red;font-family:dotum;font-weight:normal;"><?=$p_comment?></span>
			</span>
		<?php }





		########################################################################
		# modal dialog
		########################################################################
		# 모달 다이얼로그 jquery ui 필요
		public function dialog() { ?>
			<div id="dialog" title="하이">
				<p id="dialogmsg"></p>
			</div>
		<?php }






		########################################################################
		# tiles_user_header
		########################################################################
		public function tiles_user_header() { ?>
			<table border="1" width="100%" height="100%" cellpadding="3" cellspacing="3">
				<tr>
					<td>
						<div style="border:1px solid white"> hello_header</div>
					</td>
				</tr>
				<tr>
					<td>
		<?php }






		########################################################################
		# tiles_user_footer
		########################################################################
		public function tiles_user_footer() { ?>
					</td>
				</tr>
				<tr>
					<td>
						<div style="border:1px solid white"> hello_footer</div>
					</td>
				</tr>
			</table>
		<?php }










		########################################################################################################
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		# admin                                                                                                #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		#                                                                                                      #
		########################################################################################################

		########################################################################
		# 상단메뉴
		########################################################################
		function app_head($navi) { ?>
			<?php
				//Nlog::put('navi', $navi);
				$active = NULL;
			?>
			<div class="app_head" id="app_head">
				<div class="app_head_left" id="app_head_left">
					<img src="<?=IMG_ASSETS_DIR?>apps_logo.png" class="logo" width="220" height="37" onclick="Mover.admin_home();"/>
					<?php if(count($navi) > 0):?>
						<?php foreach($navi['res'] as $key=>$val):?>
							<img src="<?=IMG_ASSETS_DIR?>admin_bar.png" class="bar" width="2" height="35" />
							<?php
								foreach($val['package_files'] as $key1=>$val1){
									if(strstr($val1, $this->phpself)){
										$active = $val['cuid'];
										$this->navi_category = $val['cuid'];
									}
								}
							?>
							<span class="link <?php if($active == $val['cuid']){ echo "active"; }?>" onclick="Mover.href('<?=$val['init']?>')"><?=$val['category_name']?></span>
						<?php endforeach;?>
					<?php endif;?>
				</div>
				<div class="app_head_right" id="app_head_right">
					<span id="anything_open" class="link" onclick="Nav.open();">나의 메뉴 열기</span>
					<span id="anything_close" class="link" onclick="Nav.close();" style="display:none;">나의 메뉴 닫기</span>
				</div>
			</div>
			<div id="anything_local_menu_wrap" class="anything_local_menu_wrap">
				<div id="anything_local_menu" class="anything_local_menu" style="display:none;">
					<div class="subject" id="subject">나의 메뉴</div>
					<div class="content" id="content1" onclick="AnythingLocalMenu.signout();">사인아웃</div>
				</div>
			</div>
		<?php }





		########################################################################
		# 타일즈-사이드바 시작
		########################################################################
		function tiles_admin_sidebar($navi) { ?>
			<?php
				//Nlog::put('navi', $navi);
			?>
			<table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0" valign="top" align="left" id="layout">
				<tr>
					<td width="220" height="100%" valign="top" rowspan="3" class="side_bar" id="sidebar_td">
						<table border="0" width="220" height="100%" cellspacing="0" cellpadding="0" valign="top" id="sidebar">
							<tr>
								<td width="209" valign="top">
								<?php if(count($navi) > 0):?>
									<?php foreach($navi['res'] as $key=>$val):?>
										<div class="sidebar_div">
											<?php foreach($val['modules'] as $key1=>$val1):?>
												<?php foreach($val1['packages'] as $key2=>$val2):?>
													<?php foreach($val2['packages_files'] as $key3=>$val3):?>
														<?php if(strstr($val3, $this->phpself)):?>
															<?php
															$style = 'style="text-decoration:underline"';
															$this->module_flag = $val1['muid'];
															break;
															?>
														<?php endif;?>
													<?endforeach;?>
												<?endforeach;?>
											<?endforeach;?>
											<?php if($val['cuid'] == $this->navi_category): ?>
												<?php foreach($val['modules'] as $key1=>$val1):?>
													<h3>
														<?php foreach($val1['packages'] as $key2=>$val2):?>
															<?php if($val1['modules_init_package'] == $val2['puid']):?>
																<a href="<?=$val2['packages_init_file']?><?=$val2['param']?>"
																	<?php if($this->module_flag == $val2['muid']):?>
																		<?=$style;?>
																	<?php endif;?>
																>
																	<?=$val1['modules_name']?>
																</a>
															<?endif;?>
														<?endforeach;?>
													</h3>
													<ul>
														<?php foreach($val1['packages'] as $key2=>$val2): ?>
															<?if($val2['package_name'] != ''):?>
															<li>
																<a href="<?=$val2['packages_init_file']?><?=$val2['param']?>"
																	<?php foreach($val2['packages_files'] as $key3=>$val3):?>
																		<?php if(strstr($val3, $this->phpself)):?>
																			style="text-decoration:underline;"
																		<?php endif;?>
																	<?php endforeach;?>
																>
																	<?=$val2['package_name']?>
																</a>
															</li>
															<?endif;?>
														<?php endforeach; ?>
													</ul>
												<?php endforeach;?>
											<?php endif; ?>
										</div>
									<?php endforeach;?>
								<?php endif;?>
		<?php }





		########################################################################
		# 타일즈-컨텐츠 시작-타이틀
		########################################################################
		function tiles_admin_contents($package_key_name='', $package_name='', $package_desc = '') { ?>
								</td>
								<td width="11" valign="top" align="left" rowspan="3">
									<div id="separator">
										<span class="separator_close" onclick="Sidebar.close();"></span>
										<span class="separator_open" onclick="Sidebar.open();" style="display:none;"></span>
										<div></div>
									</div>
								</td>
							</tr>
						</table>
					</td>
					<td width="*" height="*" align="center" valign="top">
						<table border="0" width="100%" height="60" cellspacing="0" cellpadding="0" valign="top" align="left" id="content">
							<tr>
								<td width="100%" height="52" valign="middle" class="title">
									<h1><?=$package_key_name?> <span class="font_silver">&gt;</span> <?=$package_name?></h1>
									<p><?=$package_desc?></p>
								</td>
							</tr>
							<tr>
								<td>
									<table border="0" height="100%" width="100%" cellspacing="5" cellpadding="5" id="wrap">
										<tr>
											<td>
		<?php }





		########################################################################
		# 타일즈-푸터
		########################################################################
		function tiles_admin_footer() { ?>
											</td>
										</tr>
									</table>
									<?=NTool::br(5);?>
								</td>
							</tr>
							<tr>
								<td align="right">
									<p class="tar" style="color:#777;">
										elapsed : <span id="elapsed"></span>&nbsp;
									</p>
								</td>
							</tr>
							<tr>
								<td height="1" style="background-color:silver" >
								</td>
							</tr>
							<tr>
								<td>
									<table border="0" height="30" width="100%" cellspacing="1" cellpadding="1">
										<tr>
											<td width="80%" valign="top">
												<p class="tal ti10" style="color:#777">
													Thank you for
													<a href="#">GGoGGo Framework</a>
													, Programmed by
													<a href="mailto:naiyumie@gmail.com">naiyumie</a>
												</p>
											</td>
											<td width="20%">
												<p class="tar" style="color:#777">버전 0.1&nbsp;</p>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		<?php }





		########################################################################
		# 페이지 포함 자바스크립트 - 시작
		########################################################################
		function page_construct_javascript() { ?>
			<script type="text/javascript" language="javascript" >
				//<![CDATA[

					/***************************************************
					 * 전역변수
					 ***************************************************/
					var PROJECT_DIR         = '<?=PROJECT_DIR?>';
					var INDEX_FILE          = '<?=INDEX_FILE?>';
					var ADMIN_INDEX_FILE    = '<?=ADMIN_INDEX_FILE?>';
					var PAGE_ERROR          = '<?=PAGE_ERROR?>';

					var IMG_ASSETS_DIR      = '<?=IMG_ASSETS_DIR?>';
					var JS_ASSETS_DIR       = '<?=JS_ASSETS_DIR?>';
					var CSS_ASSETS_DIR      = '<?=CSS_ASSETS_DIR?>';

					var URI                 = "http://" + document.location.host;
			//]]>
			</script>
		<?php }





		########################################################################
		# 페이지 포함 자바스크립트 - 끝
		########################################################################
		function page_destruct_javascript() { ?>
				<script type="text/javascript" language="javascript">
				//<![CDATA[
					var CheckboxUi = {
						focus_to_check:function(obj){
							$(obj).attr('checked','checked');
						}
					}

					var AnythingLocalMenu = {
						signout:function(){
							AjaxAction.call({
								"url" : {throw_url:"admin.auth.process"},
								"val" : {mode:"signout_ajax"},
								"callback" : {func_success:AnythingLocalMenu.signout_success, func_failed:AnythingLocalMenu.signout_failed}
							});
						},
						signout_success:function(){
							Mover.href('admin.auth.index?mode=signout');
						},
						signout_failed:function(){
							alert("정상적인 사인아웃이 실패 하였습니다.\n잠시후 재시도 하여 주십시오.");
						}
					}

					var Sidebar = {
						open:function(){
							$("#sidebar").add("#sidebar_td").attr('width','220');
							$(".separator_close").add(".sidebar_div").attr('style','display:block;overflow:hidden;');
							$(".separator_open").attr('style','display:none;');
							this.status('open');
						},
						close:function(){
							$("#sidebar").add("#sidebar_td").attr('width','11');
							$(".separator_close").add(".sidebar_div").attr('style','display:none;overflow:hidden;width:0px;height:0px;');
							$(".separator_open").attr('style','display:block;');
							this.status('close');
						},
						status:function(status){
							AjaxAction.call({
								"url" : {throw_url:"admin.bootcamp.process"},
								"val" : {mode:"sidebar",status:status},
								"callback" : {func_success:Sidebar.success, func_failed:Sidebar.failed}
							});
						},
						success:function(){
							//alert('save status');
						},
						failed:function(){
							alert('failed change save status');
						}
					}
					var Nav = {
						open:function(){
							$("#anything_open").attr('style','display:none;');
							$("#anything_close").attr('style','display:block;');
							$("#anything_local_menu").attr('style','display:block;');
						},
						close:function(){
							$("#anything_open").attr('style','display:block;');
							$("#anything_close").attr('style','display:none;');
							$("#anything_local_menu").attr('style','display:none;');
						}
					}
					$(function(){
						/*separator*/
						$("#separator").css('margin-top', (document.body.scrollHeight/2)-37);
						$("#separator div").css('height', (((document.body.scrollHeight/2))-$("#separator .separator_close").height()) );

						/*buttons*/
						$(".cbtn_s").add(".cbtn_m").add(".cbtn_l").add(".cbtn_xl").add(".cbtn_xxl").add(".btn_s").add(".btn_m").add(".btn_l").add(".btn_xl").add(".btn_xxl")
						.mouseover(function(){
							$(this).css('color','red');
						}).mouseout(function(){
							$(this).css('color','');
						});

						<?php
							# 사이드바의 열기/닫기 상태 유지.
							global $sidebar;
							$sidebar_status = $sidebar->get_status();
							echo sprintf('Sidebar.%s();',$sidebar_status);

						?>

					});

			//]]>
			</script>
		<?php }
	} ?><?php //Nlog::xmp('/classes/class.Template.php');?>